package com.tedu.ajax.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/10/12
 */
@RestController
public class AjaxController {

    private List<String> list = new ArrayList<>();

    @GetMapping("/doAjaxGet")
    public String doAjaxGet(){
        return "Ajax get request result";
    }

    @GetMapping("/doCheck")
    public String doCheck(String name){
        list.add("java");
        return list.contains(name)?name+"已存在":"";
    }

    @PostMapping("/doSave")
    public String doSave(String name){
        list.add(name);
        return "成功";
    }
}
